| Conditions | 2 |
| Total Lines | 24 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { CommandHandler } from '@nestjs/cqrs'; |
||
| 20 | |||
| 21 | public async execute(command: UpdateEventCommand): Promise<string> { |
||
| 22 | const { id, date, summary, userId, schoolId } = command; |
||
| 23 | |||
| 24 | const event = await this.eventRepository.findOneById(id); |
||
| 25 | if (!event) { |
||
| 26 | throw new EventNotFoundException(); |
||
| 27 | } |
||
| 28 | |||
| 29 | const [ user, school ] = await Promise.all([ |
||
| 30 | this.getUser(userId), |
||
| 31 | this.getSchool(schoolId) |
||
| 32 | ]); |
||
| 33 | |||
| 34 | event.update( |
||
| 35 | date, |
||
| 36 | user, |
||
| 37 | school, |
||
| 38 | summary |
||
| 39 | ); |
||
| 40 | |||
| 41 | await this.eventRepository.save(event); |
||
| 42 | |||
| 43 | return event.getId(); |
||
| 44 | } |
||
| 46 |